package servlet;

import pojo.Project;
import service.ProjectService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class ProjectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
       String action= req.getParameter("action");
       if (action.equals("Add")){

       }
       else  if (action.equals("query")){

       }
       else  if(action.equals("select")){
           ProjectService projectService=new ProjectService();
           List<Project> projectList;
           projectList=projectService.getAllProject();
//           req.getRequestDispatcher("project_list").forward(req,resp);
           req.setAttribute("projectList",projectList);
           req.getRequestDispatcher("project_list.jsp").forward(req,resp);

       }
       else  if (action.equals("delete")){

       }
       else {

       }
    }

}
